<%@ page import="com.jspsmart.upload.SmartUpload" %>
<%@ page import="com.jspsmart.upload.Request" %>
<%@ page import="entity.Users" %>
<%@ page import="dao.IReplyDao" %>
<%@ page import="dao.impl.ReplyDaoImpl" %>
<%@ page import="entity.Topic" %>
<%@ page import="entity.Reply" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/4/8
  Time: 10:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    SmartUpload sm=new SmartUpload();
    sm.initialize(pageContext);
    sm.setCharset("UTF-8");
    sm.upload();
    sm.save("fil");
    Request srt=sm.getRequest();
    Integer hid= (Integer) session.getAttribute("h");
    Users user= (Users) session.getAttribute("user");
    int id= user.getUid();
    String mcontent=srt.getParameter("mcontent");
    String pic=sm.getFiles().getFile(0).getFileName();
    Reply r=new Reply(mcontent,pic,new Users(id),new Topic(hid));
    IReplyDao ipd=new ReplyDaoImpl();

    int b=ipd.addReply(r);

    if (b>0){
        out.print("<script>alert('添加成功');location.href='main.jsp';</script>");
    }else {
        out.print("<script>alert('添加失败');location.href='main.jsp';</script>");
    }

%>

</body>
</html>
